﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Controls_Ps_Left : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            Spro_ej();
            Spro_pro();
        }
    }
    public void Spro_ej()
    {
        DataTable dt = Class1.ExecSel("select  Menu_ID,Menu_Name,Menu_Level,Menu_ParentLevel,Menu_Lock from PsClass where Menu_Level=1 and Menu_Lock=0 order by Menu_ID desc");
        dl_ej.DataSource = dt;
        dl_ej.DataKeyField = "Menu_ID";
        dl_ej.DataBind();

    }
    public void Spro_pro()
    {
        DataTable dt = Class1.ExecSel("select  Menu_ID,Menu_Name,Menu_Level,Menu_ParentLevel,Menu_Lock from Class where Menu_Level=1 and Menu_Lock=0 order by Menu_ID asc");
        dl_pro.DataSource = dt;
        dl_pro.DataKeyField = "Menu_ID";
        dl_pro.DataBind();

    }
    protected void dl_pro_DataBinding(object sender, DataListItemEventArgs e)
    {
        Label Label1 = (Label)e.Item.FindControl("Label1");
        Label Label2 = (Label)e.Item.FindControl("Label2");
        string strSQL = "select * from Class where Menu_ParentLevel=" + this.dl_pro.DataKeys[e.Item.ItemIndex].ToString() + " and Menu_Lock=0";
        IDataReader dr = Class1.GetDataReader(strSQL);
        while (dr.Read())
        {
            Label1.Text += " <a href='wjTrade_" + dr["Menu_ID"].ToString() + ".html' target=_blank>" + dr["Menu_Name"].ToString() + "</a> |";
        }

        DataTable dt2 = Class1.ExecSel("select * from Product where p_b_ID=" + this.dl_pro.DataKeys[e.Item.ItemIndex].ToString() + "");
        Label2.Text = dt2.Rows.Count.ToString();

    }
    protected void dl_ej_DataBinding(object sender, DataListItemEventArgs e)
    {
        Label Label1 = (Label)e.Item.FindControl("Label1");
        Label Label2 = (Label)e.Item.FindControl("Label2");
        string strSQL = "select * from PsClass where Menu_ParentLevel=" + this.dl_ej.DataKeys[e.Item.ItemIndex].ToString() + " and Menu_Lock=0";
        IDataReader dr = Class1.GetDataReader(strSQL);
        while (dr.Read())
        {
            Label1.Text += " <a href='wj_Delivery-" + dr["Menu_ID"].ToString() + ".html'>" + dr["Menu_Name"].ToString() + "</a> |";
        }

        DataTable dt2 = Class1.ExecSel("select * from Delivery where p_b_ID=" + this.dl_ej.DataKeys[e.Item.ItemIndex].ToString() + "");
        Label2.Text = dt2.Rows.Count.ToString();

    }
}
